<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html lang="zh-CN">
<head>
	<meta charset="utf-8">
	<title>Dashboard Template for Bootstrap</title>
	<link rel="stylesheet" type="text/css" href="/xiaomi/Public/css/type.css" />
	<script src="/xiaomi/Public/js/jquery.min.js"></script>
</head>
<body class="admin_layout">
<header class="admin_header">
	<h2>小米商城后台管理系统</h2> 
  <ul>
		<li>欢迎您：</li>
		<li><a href="/xiaomi/index.php?s=/Admin/Administrator/modifySellerInformation"><?php echo ($_SESSION['admin_name']); ?>&emsp;</a></li>
		<li>|</li>
		<li><a href="/xiaomi/index.php?s=">&emsp;前台首页&emsp;</a></li>
		<li>|</li>
		<li><a href="/xiaomi/index.php?s=/Admin/Administrator/logout"  onClick="return confirm('您确定要退出本站?');">&emsp;退出登录&emsp;</a></li>
	</ul>
  
</header>


<div class="admin_main">
<aside class="sidebar" id="selector">
	<ul>
		<li><a href="/xiaomi/index.php?s=/Admin/Index/index" id="">后台首页</a></li>
		<li><a href="/xiaomi/index.php?s=/Admin/Goodcategory/index" id="">分类管理</a></li>
		<li><a href="/xiaomi/index.php?s=/Admin/Goodattribute/checkGoodAttribute" id="">商品属性</a></li>
		<li><a href="/xiaomi/index.php?s=/Admin/Goods/checkGoods" id="">商品管理</a></li>
		<li><a href="/xiaomi/index.php?s=/Admin/Goods/recycleIndex" id="">下架商品</a></li>
		<li><a href="/xiaomi/index.php?s=/Admin/Order/index" id="">订单管理</a></li>
		<li><a href="/xiaomi/index.php?s=/Admin/Orderdetail/index" id="">评论管理</a></li>
	<li><a href="/xiaomi/index.php?s=/Admin/User/index" id="">顾客管理</a></li>
</ul>
</aside>
<section class="admin_section">
	<div>
	<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>goods add</title>
<link rel="stylesheet" type="text/css" href="/xiaomi/Public/css/type.css" />
<link rel="stylesheet" type="text/css" href="/xiaomi/Public/css/tab.css" />
<script type="text/javascript" src="/xiaomi/Public/js/admin.js"></script>
<script type="text/javascript" src="/xiaomi/Public/js/jquery.min.js"></script>
<link href="/xiaomi/Public/ueditor/themes/default/css/umeditor.min.css"
	rel="stylesheet" />
<script src="/xiaomi/Public/ueditor/third-party/jquery.min.js"></script>
<script src="/xiaomi/Public/ueditor/umeditor.config.js"></script>
<script src="/xiaomi/Public/ueditor/umeditor.min.js"></script>
<script src="/xiaomi/Public/ueditor/lang/zh-cn/zh-cn.js"></script>
<style>
#checkGoodName,#checkPrice,#checkNumber,#checkVersion,#checkColor,#checkImg
	{
	color: red;
	margin-left: 10px;
}
</style>
<script>
$(function(){
	
	function addattribute(){
		$.post("/xiaomi/index.php?s=/Admin/Goodattribute/checkattrajax",{GoodcategoryId: $("#categorysel").val()},function(msg){
					//ajax调用php中本控制器的函数
			$(".new_add").remove();
			if (msg === false) {		//若添加子类失败，返回该信息
				alert('添加失败');
				return false;
			}
			var html="";
			if(msg==null){return;}
		for(var i=0;i<msg.length;i++){
			 html+='<tr class="new_add"><td class="classify_tbody">'+msg[i]['AttributeName']
			 +'</td><input type="hidden" name="goodattribute_GoodAttributeid[]" value="'+msg[i]['GoodAttributeid']+'">'
			 +'<td class="classify_tbody"><input type="text" name="AttributeValue[]" value="'+msg[i]['AttributeDefVal']
			 +'"></td></tr>';
		}
		$("#attribute").append(html);
//----------------------------------------------------------
//----------------------------------------------------------
        },'json');
	}
	addattribute();
	$("#categorysel").change(
		function(){
			addattribute();
		}
	);

//-------逐一判断输入框的值
	$("input[name='Color']").change(function(){
		if($("input[name='Color']").val()==''){$('#checkColor').html('商品颜色不能为空!');}
	else if($(this).val().indexOf("@")>-1)$('#checkColor').html('商品颜色中不能含有"@"');
		else $('#checkColor').html('');
	});
	$("input[name='Version']").change(function(){
		if($("input[name='Version']").val()==''){$('#checkVersion').html('商品型号不能为空!');}
		else if($(this).val().indexOf("@")>-1)$('#checkVersion').html('商品型号中不能含有"@"');
		else $('#checkVersion').html('');
	});
	$("input[name='GoodName']").change(function(){
		if($(this).val()=='')$('#checkGoodName').html('商品名称不可为空！');
		else $('#checkGoodName').html('');
	});
	$("input[name='Number']").change(function(){
		if($(this).val()%1 !== 0)$('#checkNumber').html('商品数量应为整数！');
		else $('#checkNumber').html('');
	});
	$("input[name='Price']").change(function(){
		if(isNaN($(this).val()))$('#checkPrice').html('商品价格应为数字！');
		else $('#checkPrice').html('');
	});
	
});

//------------------判断输入框是否正确
function checkinput(){
	var flag=true;
	if($("input[name='Color']").val()==''){$('#checkColor').html('商品颜色不能为空!');flag=false;}
	if($("input[name='Version']").val()==''){$('#checkVersion').html('商品型号不能为空!');flag=false;}
	if($("input[name='img']").val()==''){$('#checkImg').html('请选择商品图片!');flag=false;}
	if($("input[name='Color']").val().indexOf("@")>-1){$('#checkColor').html('商品颜色中不能含有"@"');flag=false;}
	if($("input[name='Version']").val().indexOf("@")>-1){$('#checkVersion').html('商品型号中不能含有"@"');flag=false;}
	if($("input[name='GoodName']").val()==''){$('#checkGoodName').html('商品名称不可为空！');flag=false;}
	if($("input[name='Number']").val()%1 !== 0){$('#checkNumber').html('商品数量应为整数！');flag=false;}
	if(isNaN($("input[name='Price']").val())){$('#checkPrice').html('商品价格应为数字！');flag=false;}
	if(flag)$("form").submit();
	else{
		alert("输入的数据不合法，请检查!");
	}
}
//----------------
</script>




<style>
.data-edit {
	border: 1px solid #ddd;
	background: #F7F7F7;
	width: auto;
	padding: 20px 40px;
}
</style>
</head>
<body>
<form method="post" enctype="multipart/form-data">
<table class="classify_table1">
	<tr>
		<td><span class="classify_table_title">新增商品</span> <span
			class="classify_table_button">
		<button><a href="/xiaomi/index.php?s=/Admin/Goods/checkGoods">返回</a></button>
		</span> <span class="classify_table_button"> <input type="button"
			value="保存" onclick="checkinput()"> </span></td>
	</tr>
	<tr>
		<td>
		<div class="goods_add_section">
		<ul id="tabs">
			<li><a href="#" title="tab1">简介</a></li>
			<li><a href="#" title="tab2">参数</a></li>
			<li><a href="#" title="tab3">属性</a></li>
			<li><a href="#" title="tab4">描述</a></li>
		</ul>

		<div id="content">
		<hr>
		<div id="tab1" class="tab ff"><span>商品名称：<input
			type="text" name="GoodName"></span><span id="checkGoodName"></span><br>
		<span>商品价格：<input type="text" name="Price"></span><span
			id="checkPrice"></span><br>
		<span>商品数量：<input type="text" name="Number"></span><span
			id="checkNumber"></span><br>
		<span>商品分类： <select name="GoodcategoryId" id="categorysel">
			<?php if(is_array($goodcategory)): foreach($goodcategory as $key=>$v): if(empty($goodcategory)): ?><option value="-1">无分类</option><?php endif; ?>
			<option value="<?php echo ($v["GoodcategoryId"]); ?>"<?php if(($v["GoodcategoryId"]) == $GoodcategoryId): ?>selected<?php endif; ?>
			><?php echo str_repeat('&nbsp;&nbsp;&nbsp;&nbsp;',$v['deep']).$v['CategoryName'];?></option><?php endforeach; endif; ?>
		</select> </span><br>
		<span>是否上架： <select name="Status" id="">
			<option value="1">是</option>
			<option value="2">否</option>
		</select> </span><br>
		<span>首页推介： <select name="Is_best" id="">
			<option value="1">是</option>
			<option value="2">否</option>
		</select> </span><br>
		</div>

		<div id="tab2" class="tab ff"><span>商品型号：<input
			type="text" name="Version"></span><span id="checkVersion"></span><br>
		<span>商品颜色：<input type="text" name="Color"></span><span
			id="checkColor"></span><br>
		<span>关键词汇：<input type="text" name="KeyWords"></span><br>
		<span>商品图片：<input type="file" name="img"></span><span
			id="checkImg"></span><br>
		</div>
		<div id="tab3" class="ff">
		<table class="goods_add_table" id="attribute">
			<tr>
				<td class="classify_thead_title">属性名</td>
				<td class="classify_thead_title">属性值</td>
			</tr>

		</table>
		</div>
		<div id="tab4" class="ff"><span id="ff"> <script
			type="text/plain" id="myEditor" name="Description"><p>这里我可以写一些输入提示</p></script>
		</span></div>
		</div>
		</div>
		</td>
	</tr>
</table>
</form>
</div>


<script>
		$(function() {
			$("#content div").hide(); // Initially hide all content
			$("#tabs link:first").attr("id","current"); // Activate first tab
			$("#content div:first").fadeIn(); // Show first tab content
		    $('#tabs a').click(function(e) {
		        e.preventDefault();        
		        $("#content div.ff").hide(); //Hide all content
		        $("#tabs li").attr("id",""); //Reset id's
		        $(this).parent().attr("id","current"); // Activate this
		        $('#' + $(this).attr('title')).fadeIn(); // Show content for current tab
		    UM.getEditor('myEditor');
		    $("#ff").fadeIn();
		    });
		});

	</script>

</body>
</html>
	</div>
</section>
</div>
</body>
</html>